package com.erebus.login.api;


import com.erebus.base.model.RestResponse;
import com.erebus.login.model.dto.StudentDto;
import com.erebus.login.model.dto.UserDto;
import com.erebus.login.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//@CrossOrigin(origins = "http://localhost:17777")  // 允许来自特定域的请求
public class LoginController {


    @Autowired
    LoginService loginService;

    // 测试
    @RequestMapping("/test/{id}")
    public String get(@PathVariable("id")  String id){

        System.out.println(id);
        return id;
    }

    // 测试
    @PostMapping("/tes")
    public String gets( ){

        System.out.println("sfhsl");

        return "fsjd";
    }

    // 老师登录
    @PostMapping("/teacher")
    public RestResponse<String> teacherLogin(@RequestBody UserDto userDto) {
        System.out.println(userDto);

        return loginService.Login(userDto);
    }

    // 学生登录
    @PostMapping("/student")
    public RestResponse<String>  studentLogin(@RequestBody UserDto userDto) {


        return loginService.Login(userDto);
    }
}
